LanguageExt.Core

LanguageExt.Core Immutable Collections

This a suite of very high-performance immutable-collections.

You can construct the collection types using the constrctor functions in the Prelude:

HashMap<string, int> hashSet = HashMap(("a", 1), ("b", 2), ("c", 3));
HashSet<int> hashMap         = HashSet(1, 2, 3);
Map<string, int> hashSet     = Map(("a", 1), ("b", 2), ("c", 3));
Set<int> hashMap             = Set(1, 2, 3);
Seq<int> list                = Seq(1, 2, 3);
Lst<int> list                = List(1, 2, 3);

Contents

Sub modules

Arr
BiMap
HashMap
HashSet
Iterable
List
Map
Queue
Seq
Set
Stack
TrackingHashMap
TrieMap
TrieSet

class Prelude Source #

Fields

field SeqEmpty Empty = new() Source #

Represents an empty sequence

Properties

property Iterable<int> Naturals Source #

Lazy sequence of natural numbers up to Int32.MaxValue

property Iterable<long> LongNaturals Source #

Lazy sequence of natural numbers up to Int64.MaxValue

Methods

method Seq<A> Cons <A> (this A head) Source #

Construct a sequence from any value

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

returns

method Seq<A> Cons <A> (this A head, SeqEmpty empty) Source #

Construct a sequence from any value

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

returns

method Seq<A> Cons <A> (this A head, Seq<A> tail) Source #

Construct a list from head and tail; head becomes the first item in the list.

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

param tail

Tail of the sequence

returns

method Seq<A> Cons <A> (this A head, A[] tail) Source #

Construct a list from head and tail; head becomes the first item in the list.

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

param tail

Tail of the sequence

returns

method Seq<A> Cons <A> (this A head, Arr<A> tail) Source #

Construct a list from head and tail; head becomes the first item in the list.

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

param tail

Tail of the sequence

returns

method Seq<A> Cons <A> (this A head, IEnumerable<A> tail) Source #

Construct a list from head and tail; head becomes the first item in the list.

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

param tail

Tail of the sequence

returns

method Lst<A> Cons <A> (this A head, Lst<A> tail) Source #

Construct a list from head and tail; head becomes the first item in the list.

Parameters

type A

Type of the items in the sequence

param head

Head item in the sequence

param tail

Tail of the sequence

returns

method IEnumerable<A> Sort <OrdA, A> (this IEnumerable<A> xs) Source #

where OrdA : Ord<A>

Provide a sorted enumerable

method Seq<A> Sort <OrdA, A> (this Seq<A> xs) Source #

where OrdA : Ord<A>

Provide a sorted Seq

method Lst<A> Sort <OrdA, A> (this Lst<A> xs) Source #

where OrdA : Ord<A>

Provide a sorted Lst

method Arr<A> Sort <OrdA, A> (this Arr<A> xs) Source #

where OrdA : Ord<A>

Provide a sorted Arr

method A[] Sort <OrdA, A> (this A[] xs) Source #

where OrdA : Ord<A>

Provide a sorted array

method Range<long> Range (long from, long count, long step = 1) Source #

Lazily generate a range of integers.

method Range<int> Range (int from, int count, int step = 1) Source #

Lazily generate a range of integers.

method Range<char> Range (char from, char to) Source #

Lazily generate a range of chars.

Remarks: Can go in a positive direction ('a'..'z') as well as negative ('z'..'a')

method Map<K, V> Map <K, V> () Source #

Create an immutable map

method Map<K, V> Map <K, V> ((K, V) head, params (K, V)[] tail) Source #

Create an immutable map

method Map<K, V> toMap <K, V> (IEnumerable<(K, V)> items) Source #

Create an immutable map

method Map<K, V> toMap <K, V> (ReadOnlySpan<(K, V)> items) Source #

Create an immutable map

method Map<OrdK, K, V> Map <OrdK, K, V> () Source #

where OrdK : Ord<K>

Create an immutable map

method Map<OrdK, K, V> Map <OrdK, K, V> ((K, V) head, params (K, V)[] tail) Source #

where OrdK : Ord<K>

Create an immutable map

method Map<OrdK, K, V> toMap <OrdK, K, V> (IEnumerable<(K, V)> items) Source #

where OrdK : Ord<K>

Create an immutable map

method Map<OrdK, K, V> toMap <OrdK, K, V> (ReadOnlySpan<(K, V)> items) Source #

where OrdK : Ord<K>

Create an immutable map

method HashMap<K, V> HashMap <K, V> () Source #

Create an immutable hash-map

method HashMap<K, V> HashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #

Create an immutable hash-map

method HashMap<K, V> toHashMap <K, V> (IEnumerable<(K, V)> items) Source #

Create an immutable hash-map

method HashMap<K, V> toHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #

Create an immutable hash-map

method HashMap<EqK, K, V> HashMap <EqK, K, V> () Source #

where EqK : Eq<K>

Create an immutable hash-map

method HashMap<EqK, K, V> HashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #

where EqK : Eq<K>

Create an immutable hash-map

method HashMap<EqK, K, V> toHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable hash-map

method HashMap<EqK, K, V> toHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable hash-map

method TrackingHashMap<K, V> TrackingHashMap <K, V> () Source #

Create an immutable tracking hash-map

method TrackingHashMap<K, V> TrackingHashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #

Create an immutable tracking hash-map

method TrackingHashMap<K, V> toTrackingHashMap <K, V> (IEnumerable<(K, V)> items) Source #

Create an immutable tracking hash-map

method TrackingHashMap<K, V> toTrackingHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #

Create an immutable tracking hash-map

method TrackingHashMap<EqK, K, V> TrackingHashMap <EqK, K, V> () Source #

where EqK : Eq<K>

Create an immutable tracking hash-map

method TrackingHashMap<EqK, K, V> TrackingHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #

where EqK : Eq<K>

Create an immutable tracking hash-map

method TrackingHashMap<EqK, K, V> toTrackingHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable tracking hash-map

method TrackingHashMap<EqK, K, V> toTrackingHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable tracking hash-map

method AtomHashMap<K, V> AtomHashMap <K, V> () Source #

Create an immutable hash-map

method AtomHashMap<K, V> AtomHashMap <K, V> ((K, V) head, params (K, V)[] tail) Source #

Create an immutable hash-map

method AtomHashMap<K, V> AtomHashMap <K, V> (HashMap<K, V> items) Source #

Create an immutable hash-map

method AtomHashMap<K, V> toAtomHashMap <K, V> (IEnumerable<(K, V)> items) Source #

Create an immutable hash-map

method AtomHashMap<K, V> toAtomHashMap <K, V> (ReadOnlySpan<(K, V)> items) Source #

Create an immutable hash-map

method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> () Source #

where EqK : Eq<K>

Create an immutable hash-map

method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> ((K, V) head, params (K, V)[] tail) Source #

where EqK : Eq<K>

Create an immutable hash-map

method AtomHashMap<EqK, K, V> AtomHashMap <EqK, K, V> (HashMap<EqK, K, V> items) Source #

where EqK : Eq<K>

Create an immutable hash-map

method AtomHashMap<EqK, K, V> toAtomHashMap <EqK, K, V> (IEnumerable<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable hash-map

method AtomHashMap<EqK, K, V> toAtomHashMap <EqK, K, V> (ReadOnlySpan<(K, V)> items) Source #

where EqK : Eq<K>

Create an immutable hash-map

method Lst<T> List <T> () Source #

Create an immutable list

method Lst<T> List <T> (T x, params T[] xs) Source #

Create an immutable list

method Lst<T> toList <T> (Arr<T> items) Source #

Create an immutable list

method Lst<T> toList <T> (IEnumerable<T> items) Source #

Create an immutable list

method Lst<T> toList <T> (ReadOnlySpan<T> items) Source #

Create an immutable list

method Arr<T> Array <T> () Source #

Create an immutable array

method Arr<T> Array <T> (T x, params T[] xs) Source #

Create an immutable array

method Arr<T> toArray <T> (IEnumerable<T> items) Source #

Create an immutable array

method Arr<T> toArray <T> (ReadOnlySpan<T> items) Source #

Create an immutable array

method Que<T> Queue <T> () Source #

Create an immutable queue

method Que<T> Queue <T> (params T[] items) Source #

Create an immutable queue

method Que<T> toQueue <T> (IEnumerable<T> items) Source #

Create an immutable queue

method Que<T> toQueue <T> (ReadOnlySpan<T> items) Source #

Create an immutable queue

method Stck<T> Stack <T> () Source #

Create an immutable stack

method Stck<T> Stack <T> (params T[] items) Source #

Create an immutable stack

method Stck<T> toStack <T> (IEnumerable<T> items) Source #

Create an immutable stack

method Stck<T> toStackRev <T> (IEnumerable<T> items) Source #

Create an immutable stack

method Map<K, V> toMapUpdate <K, V> (IEnumerable<(K, V)> keyValues) Source #

Create an immutable map, updating duplicates so that the final value of any key is retained

method Map<K, V> toMapUpdate <K, V> (ReadOnlySpan<(K, V)> keyValues) Source #

Create an immutable map, updating duplicates so that the final value of any key is retained

method Map<K, V> toMapTry <K, V> (IEnumerable<(K, V)> keyValues) Source #

Create an immutable map, ignoring duplicates so the first value of any key is retained

method Map<K, V> toMapTry <K, V> (ReadOnlySpan<(K, V)> keyValues) Source #

Create an immutable map, ignoring duplicates so the first value of any key is retained

method Set<T> Set <T> () Source #

Create an immutable set

method Set<T> Set <T> (T head, params T[] tail) Source #

Create an immutable set

method Set<T> toSet <T> (IEnumerable<T> items) Source #

Create an immutable set

method Set<T> toSet <T> (ReadOnlySpan<T> items) Source #

Create an immutable set

method Set<OrdT, T> Set <OrdT, T> () Source #

where OrdT : Ord<T>

Create an immutable set

method Set<OrdT, T> Set <OrdT, T> (T head, params T[] tail) Source #

where OrdT : Ord<T>

Create an immutable set

method Set<OrdT, T> toSet <OrdT, T> (IEnumerable<T> items) Source #

where OrdT : Ord<T>

Create an immutable set

method Set<OrdT, T> toSet <OrdT, T> (ReadOnlySpan<T> items) Source #

where OrdT : Ord<T>

Create an immutable set

method HashSet<T> HashSet <T> () Source #

Create an immutable hash-set

method HashSet<T> HashSet <T> (T head, params T[] tail) Source #

Create an immutable hash-set

method HashSet<T> toHashSet <T> (IEnumerable<T> items) Source #

Create an immutable hash-set

method HashSet<T> toHashSet <T> (ReadOnlySpan<T> items) Source #

Create an immutable hash-set

method HashSet<EqT, T> HashSet <EqT, T> () Source #

where EqT : Eq<T>

Create an immutable hash-set

method HashSet<EqT, T> HashSet <EqT, T> (T head, params T[] tail) Source #

where EqT : Eq<T>

Create an immutable hash-set

method HashSet<EqT, T> toHashSet <EqT, T> (IEnumerable<T> items) Source #

where EqT : Eq<T>

Create an immutable hash-set

method HashSet<EqT, T> toHashSet <EqT, T> (ReadOnlySpan<T> items) Source #

where EqT : Eq<T>

Create an immutable hash-set

method IQueryable<T> Query <T> (params T[] items) Source #

Create a queryable

method IQueryable<T> toQuery <T> (IEnumerable<T> items) Source #

Convert to queryable

method B match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<Seq<A>, B> More) Source #

Match empty list, or multi-item list

Parameters

type B

Return value type

param Empty

Match for an empty list

param More

Match for a non-empty

returns

Result of match function invoked

method B match <A, B> (IEnumerable<A> list, Func<B> Empty, Func<A, Seq<A>, B> More) Source #

List pattern matching

method R match <T, R> (IEnumerable<T> list, Func<R> Empty, Func<T, R> One, Func<T, Seq<T>, R> More) Source #

List pattern matching

method R match <K, V, R> (Map<K, V> map, K key, Func<V, R> Some, Func<R> None) Source #

method Unit match <K, V> (Map<K, V> map, K key, Action<V> Some, Action None) Source #

method R match <K, V, R> (HashMap<K, V> map, K key, Func<V, R> Some, Func<R> None) Source #

method Unit match <K, V> (HashMap<K, V> map, K key, Action<V> Some, Action None) Source #

method Iterable<A> Iterable <A> () Source #

Construct an empty Iterable

method Iterable<A> Iterable <A> (ReadOnlySpan<A> value) Source #

Construct a sequence from an Enumerable

method Iterable<A> Iterable <A> (A fst, A snd, params A[] rest) Source #

Construct a sequence from an Enumerable

method Iterable<A> Iterable <A> (IEnumerable<A>? value) Source #

Construct a sequence from an Enumerable Deals with value == null by returning [] and also memoizes the items in the enumerable as they're being consumed.

method Seq<A> Seq <A> () Source #

Construct an empty Seq

method Seq<A> Seq1 <A> (A value) Source #

Construct a sequence from any value

var list = Seq1(124);

method Seq<A> Seq <A> (A value) Source #

Construct a singleton sequence from any value

var list = Seq(1);

method Seq<A> Seq <A> (A a, A b) Source #

Construct a sequence from any value

var list = Seq(1, 2);

method Seq<A> Seq <A> (A a, A b, A c) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3);

method Seq<A> Seq <A> (A a, A b, A c, A d) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4);

method Seq<A> Seq <A> (A a, A b, A c, A d, A e) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4, 5);

method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4, 5, 6);

method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4, 5, 6, 7);

method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4, 5, 6, 7, 8);

method Seq<A> Seq <A> (A a, A b, A c, A d, A e, A f, A g, A h, params A[] tail) Source #

Construct a sequence from any value

var list = Seq(1, 2, 3, 4);

method Seq<A> Seq <A> (ReadOnlySpan<A> value) Source #

Construct a sequence from an Enumerable Deals with value == null by returning [] and also memoizes the items in the enumerable as they're being consumed.

method Seq<A> Seq <A> (IEnumerable<A>? value) Source #

Construct a sequence from an Enumerable Deals with value == null by returning [] and also memoizes the items in the enumerable as they're being consumed.

method Seq<A> toSeq <A> (IEnumerable<A>? value) Source #

Construct a sequence from an Enumerable Deals with value == null by returning [] and also memoizes the items in the enumerable as they're being consumed.

method Seq<A> toSeq <A> (A? value) Source #

where A : struct

Construct a sequence from a nullable HasValue == true : [x] HasValue == false : []

method Seq<A> toSeq <A> (A[]? value) Source #

Construct a sequence from an array

method Seq<A> toSeq <A> (Arr<A> value) Source #

Construct a sequence from an immutable array

method Seq<A> toSeq <A> (IList<A>? value) Source #

Construct a sequence from a list

method Seq<A> toSeq <A> (ICollection<A>? value) Source #

Construct a sequence from a list

method Seq<R> toSeq <L, R> (Either<L, R> value) Source #

Construct a sequence from an either Right(x) : [x] Left(y) : []

method Seq<A> toSeq <A> (ValueTuple<A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A, A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A, A, A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A, A, A, A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A, A, A, A, A> tup) Source #

Construct a sequence from a tuple

method Seq<A> toSeq <A> (ValueTuple<A, A, A, A, A, A, A> tup) Source #

Construct a sequence from a tuple

method AtomSeq<A> AtomSeq <A> () Source #

Construct an empty AtomSeq

method AtomSeq<A> AtomSeq <A> (params A[] items) Source #

Construct an AtomSeq

method AtomSeq<A> AtomSeq <A> (Seq<A> items) Source #

Construct an AtomSeq

method AtomSeq<A> AtomSeq <A> (IEnumerable<A> items) Source #

Construct an AtomSeq

method Patch<EqA, A> Diff <EqA, A> (this IEnumerable<A> va, IEnumerable<A> vb) Source #

where EqA : Eq<A>

Compute the difference between two documents, using the Wagner-Fischer algorithm. O(mn) time and space.

apply(diff(d,e), d) == e

diff(d, d) == Patch.empty

apply(diff(d, e), d) == apply(inverse(diff(e, d)), d)

apply(append(diff(a, b), diff(b, c), a) == apply(diff(a, c), a)

applicable(diff(a, b) a)

method IEnumerable<A> Apply <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method Lst<A> Apply <EqA, A> (this Lst<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method Seq<A> Apply <EqA, A> (this Seq<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method SpanArray<A> Apply <EqA, A> (this SpanArray<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method A[] Apply <EqA, A> (this A[] va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method Arr<A> Apply <EqA, A> (this Arr<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method List<A> Apply <EqA, A> (this List<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Apply the supplied patch to this collection

method bool Applicable <EqA, A> (this IEnumerable<A> va, Patch<EqA, A> patch) Source #

where EqA : Eq<A>

Returns true if a patch can be safely applied to a document, that is, applicable(p, d) holds when d is a valid source document for the patch p.